package com.baitao.demo3;

import java.io.UnsupportedEncodingException;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.widget.Toast;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getData();
    }
    private void getData(){
    	RequestQueue mQueue = Volley.newRequestQueue(getBaseContext());  
    	StringRequest stringRequest = new StringRequest("http://php.weather.sina.com.cn/xml.php?" +
    			"city=%B1%B1%BE%A9&password=DJOYnieT8234jlsK&day=0",  
                new Response.Listener<String>() {  
                    @Override  
                    public void onResponse(String response) {  
                    	try {
							Toast.makeText(getApplicationContext(), new String(response.getBytes("ISO-8859-1"),"utf-8"), Toast.LENGTH_LONG).show();
						} catch (UnsupportedEncodingException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}  
                    }  
                }, new Response.ErrorListener() {  
                    @Override  
                    public void onErrorResponse(VolleyError error) {  
                        Log.e("TAG", error.getMessage(), error);  
                    }
  
                });  
    	mQueue.add(stringRequest);  
    }
     
}
